package com.example.aboutspringboot.mapper;

import com.example.aboutspringboot.entity.ShopCar;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShopCarMapper {

    @Select("select username,shop.id,number,name,weight,issueDate,price from shopCar,shop where username=#{username} and shop.id=ShopCar.id")
    List<ShopCar> selectShopCar(String username);

    @Insert("insert into shopCar(username,id,number) values(#{username},#{id},#{number})")
    int insertShopCar(ShopCar shopCar);

    @Update("update shopCar set number=#{number} where username=#{username} and id=#{id}")
    int updateShopCar(ShopCar shopCar);

    @Delete("delete from shopCar where username=#{username}")
    int deleteShopCarAll(String username);

    @Delete("delete from shopCar where username=#{username} and id=#{id} ")
    int deleteShopCarByNum(String username,long id);

    @Select("select username,id,number from shopCar where username=#{username} and id=#{id}")
    ShopCar selectShopCarByIdAndName(String username,long id);
}
